package com.cztv.vote.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class ResultServlet extends HttpServlet {

	private static final long serialVersionUID = 3834075500269204311L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int input=Integer.parseInt(request.getParameter("c"));
		String checkId=request.getParameter("id");
		HttpSession session=request.getSession();
		
		int result=Integer.parseInt(String.valueOf(session.getAttribute(checkId)));
		session.removeAttribute(checkId);
		String info="true";
		if(input!=result)
			info="验证码错误！";

		response.setContentType("text/html");
		response.setHeader("Content-Type", "text/html;charset=GB2312");
		PrintWriter out = response.getWriter();
		out.print(info);
		out.flush();
		out.close();
	}

}
